import request from "@/utils/request";
import qs from "qs";

export function login(data) {
  let params = qs.stringify(data);
  return request({
    url: "/connect/token",
    method: "post",
    headers: {
      "content-type": "application/x-www-form-urlencoded",
    },
    data: params,
  });
}



export function getInfo(token) {
  return request({
    url: "/connect/userinfo",
    method: "get",
  });
}

export function logout(token) {
  return request({
    url: "/api/account/logout",
    method: "get",
  });
}

export function getAppConfiguration(token) {
  return request({
    url: "/api/abp/application-configuration",
    method: "get",
  });
}

export function getUsers(paramters) {
  let url = "/api/identity/users/";
  return request({
    url: url,
    method: "get",
    params: paramters,
  });
}

export function getUser(id) {
  let url = "/api/identity/users/" + id;
  return request({
    url: url,
    method: "get",
  });
}

export function getUserRoles(id) {
  let url = "/api/identity/users/" + id + "/roles";
  return request({
    url: url,
    method: "get",
  });
}

export function addUser(data) {
  let url = "/api/identity/users/";
  return request({
    url: url,
    method: "post",
    data: data,
  });
}

export function updateUser(data) {
  let url = "/api/identity/users/" + data.id;
  return request({
    url: url,
    method: "put",
    data: data,
  });
}

export function deleteUser(id) {
  let url = "/api/identity/users/" + id;
  return request({
    url: url,
    method: "delete",
  });
}
